package com.share.common.enums;

import lombok.Getter;

@Getter
public enum ScriptEnum {
    JSON_PATH(1, "json_path", "jsonPath"),
    GROOVY(2, "groovy", "groovy脚本"),

    JAVA(3, "java", "java代码");

    public Integer id;

    //主题编码
    public String code;

    //主题名字
    public String name;

    ScriptEnum(int id, final String code, final String name) {
        this.id = id;
        this.code = code;
        this.name = name;
    }

    public static ScriptEnum toEnumById(final Integer id) {
        for (final ScriptEnum tag : ScriptEnum.values()) {
            if (tag.id.equals(id)) {
                return tag;
            }
        }
        return null;
    }

    public static ScriptEnum toEnumByCode(final String code) {
        for (final ScriptEnum tag : ScriptEnum.values()) {
            if (tag.code.equals(code)) {
                return tag;
            }
        }
        return null;
    }
}
